#include <iostream>
#include<vector>
using namespace std;

int main() {
    int n,q;
    cin >> n >> q;
    vector<int> v1(n + 1);
    for(int i = 1; i <= n; i++)
    {
        cin >> v1[i];
    }
    vector<long long> dp(n + 1);
    for(int i = 1; i <= n; i++)
    {
        dp[i] = dp[i - 1] + v1[i];
    }

    int l , r;
    while(q--)
    {
        cin >> l >> r;
        cout << dp[r] - dp[l - 1] << endl;
    }
}
